﻿using MgSoft.Import.Exchange.ExWebApi.Db.Daos;
using MgSoft.Import.Exchange.ExWebApi.Db.Dtos;
using System;
using System.Collections.Generic;
using System.Text;

namespace MgSoft.Import.Exchange.ExWebApi.Db.Services
{
    public class SyncExtensionService: ISyncExtensionService
    {
        private readonly ISyncExtensionDao syncExtensionDao;

        public SyncExtensionService(ISyncExtensionDao syncExtensionDao)
        {
            this.syncExtensionDao = syncExtensionDao;
        }

        public virtual void AddSync(SyncExtensionDto syncExtensionDto)
        {
            var obj = Get(syncExtensionDto.OrgNumber, syncExtensionDto.Biz_BillType);
            if (obj is null)
            {
                syncExtensionDao.AddSyncData(syncExtensionDto);
            }
            else
            {
                syncExtensionDao.UpdateFilterField(syncExtensionDto);
            }
        }

        public virtual SyncExtensionDto Get(string orgNumberValue, string Biz_BillType)
        {
            return syncExtensionDao.Get(orgNumberValue, Biz_BillType);
        }
    }
}
